﻿@model ProductModel.ProductVariantAttributeModel

@{
    var parentModel = ViewData["Parent"] as ProductModel;
}

<datagrid id="productvariantattributes-grid" version="2"
          allow-resize="true"
          allow-row-selection="true"
          allow-edit="true"
          allow-column-reordering="true"
          max-height="500px">
    <datasource read="@Url.Action("ProductVariantAttributeList", new { productId = parentModel.Id })"
                delete="@Url.Action("ProductVariantAttributeDelete")"
                update="@Url.Action("ProductVariantAttributeUpdate")"
                insert="@Url.Action("ProductVariantAttributeInsert", new { productId = parentModel.Id })" />
    <sorting enabled="true">
        <sort by="DisplayOrder" by-entity-member="DisplayOrder" />
    </sorting>
    <paging enabled="true" page-size="10" />
    <toolbar>
        <toolbar-group>
            <button datagrid-action="DataGridToolAction.InsertRow" type="button" class="btn btn-primary btn-flat no-anims mr-auto">
                <i class="fa fa-plus"></i>
                <span>@T("Admin.Common.AddNew")</span>
            </button>
            <button datagrid-action="DataGridToolAction.SaveChanges" type="button" class="btn btn-warning no-anims btn-flat">
                <i class="fa fa-check"></i>
                <span>@T("Admin.Common.SaveChanges")</span>
            </button>
            <button datagrid-action="DataGridToolAction.CancelEdit" type="button" class="btn btn-light btn-flat mr-auto">
                <span>@T("Common.Cancel")</span>
            </button>
        </toolbar-group>
        <zone name="productvariantattribute_datagrid_toolbar_alpha"></zone>
        <toolbar-group class="omega"></toolbar-group>
        <zone name="productvariantattribute_datagrid_toolbar_omega"></zone>
        <toolbar-group>
            <button datagrid-action="DataGridToolAction.DeleteSelectedRows" type="button" class="btn btn-danger no-anims btn-flat">
                <i class="far fa-trash-can"></i>
                <span>@T("Admin.Common.Delete.Selected")</span>
            </button>
        </toolbar-group>
    </toolbar>
    <columns>
        <column for="ProductAttributeId" hideable="false" width="2fr">
            <display-template>
                <div class="dg-cell-value">{{ item.row.ProductAttribute }}</div>
            </display-template>
        </column>
        <column for="AttributeControlTypeId" width="2fr">
            <display-template>
                <div class="dg-cell-value">{{ item.row.AttributeControlType }}</div>
            </display-template>
        </column>
        <column for="TextPrompt" width="1fr" visible="false" />
        <column for="CustomData" width="1fr" visible="false" />
        <column for="IsRequired" halign="center" />
        <column for="DisplayOrder" entity-member="DisplayOrder" halign="center" />
        <column for="EditUrl" width="1fr" sortable="false">
            <display-template>
                <a :href="item.row.EditUrl" v-html="item.row.EditLinkText"></a>
            </display-template>
            <edit-template>
                <div v-if="item.row.OptionSets.length > 0" :id="'OptionsSetsContainer' + item.row.Id">
                    <select class='form-control' :id="'OptionsSetsChoice' + item.row.Id" :data-valcount='item.row.NumberOfOptions'>
                        <option v-for="o in item.row.OptionSets" v-bind:value="o.Id">{{ o.Name }}</option>
                    </select>
                </div>
            </edit-template>
        </column>
    </columns>
    <row-commands>
        <a datarow-action="DataRowAction.InlineEdit">@T("Common.Edit")</a>
        <a datarow-action="DataRowAction.Delete">@T("Common.Delete")</a>
    </row-commands>
</datagrid>
